package com.tdtech.keycloak.demo1.dao;


import com.tdtech.keycloak.demo1.entity.Customer;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * 模拟DAO层
 */
@Component
public class CustomerDAO {

    public static List<Customer> customers = new ArrayList<>();

    static {
            Customer customer1 = new Customer();
            customer1.setAddress("1111 foo blvd");
            customer1.setName("Foo Industries");
            customer1.setServiceRendered("Important services");
            customers.add(customer1);

            Customer customer2 = new Customer();
            customer2.setAddress("2222 bar street");
            customer2.setName("Bar LLP");
            customer2.setServiceRendered("Important services");
            customers.add(customer2);

            Customer customer3 = new Customer();
            customer3.setAddress("33 main street");
            customer3.setName("Big LLC");
            customer3.setServiceRendered("Important services");
            customers.add(customer3);
    }

    public List<Customer> findAll() {

        return customers;
    }

    public void save(Customer customer) {
        customers.add(customer);
    }

}
